require 'rubygems'
gem 'soap4r'
require 'soap/wsdlDriver'
require 'soap/header/simplehandler'
require 'defaultDriver.rb'
require 'authStub.rb'
require 'WSHelpers.rb'

props = {
  :object => 'List',
  :props => ['ListName','Description','Type','ID']
}

filter = {
  :filterType => 'Simple',
  :filter => ['ListName','like','API-TestList']
}

lists = BuildRetrieve.new
resp = lists.creates(props,filter)

#Async update options
#options = CreateOptions.new(nil,nil,nil,nil,nil,nil,nil,nil,'Asynchronous')
#Upsert update options
options = UpdateOptions.new(nil,nil,SaveOption.new('List','UpdateAdd'),nil,nil,nil,nil,nil,nil,nil,nil,nil)
#options = nil

listObjs = []
date = Date.today.strftime("%m/%d/%Y")
resp.results.each do |result, i|
  listType = 'Public'
  listObjs.push(List.new(nil,nil,nil,nil,nil,result.iD,nil,result.customerKey,nil,nil,result.listName,nil,listType,result.description + " " + date))
end
apiObj = listObjs

resp = $driver.update(UpdateRequest.new(options,[*apiObj]))